package com.lightChat.mapper;


import com.lightChat.entity.Users;
import org.apache.catalina.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author sxt
 * @create 2019-11-06 21:25
 */

@Mapper
public interface UsersMapper {

    /**
     * 查询数据库中所有的用户信息
     * @return
     */
    @Select("select * from users")
    List<Users> selectAllUsers();

    @Insert("insert into users(id,username,password,face_image,face_image_big,nickname,qrcode) values(#{id},#{username},#{password}," +
            "#{faceImage},#{faceImageBig},'',#{qrcode})")
    void addUser(Users users);

    @Select("select * from users where username = #{username}  and password =  #{password}   ")
    Users selectUserByUsernameAndPassword(Users users);

    @Select("select * from users where username = #{username}")
    Users selectUserByUsername(String username);

    @Select("select * from friends_request where accept_user_id = #{userId}")
    List<Users> selectFriendRequestById(String userId);

}
